<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!doctype html>
<html lang="en"><head>
    <meta charset="utf-8">
    <title>商品详细信息</title>
    <meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>lib/bootstrap/css/bootstrap.css">
    <link rel="stylesheet" href="<%=basePath%>lib/font-awesome/css/font-awesome.css">

    <script src="<%=basePath%>lib/jquery-1.11.1.min.js" type="text/javascript"></script>

    

    <link rel="stylesheet" type="text/css" href="<%=basePath%>stylesheets/theme.css">
    <link rel="stylesheet" type="text/css" href="<%=basePath%>stylesheets/premium.css">


     <!-- Demo page code -->

    <script type="text/javascript">
        
    </script>
    <style type="text/css">
        #line-chart {
            height:300px;
            width:800px;
            margin: 0px auto;
            margin-top: 1em;
        }
        .navbar-default .navbar-brand, .navbar-default .navbar-brand:hover { 
            color: #fff;
        }



    </style>

   
    <script type="text/javascript">
        $(document).ready(function(){
            var add,reduce,num,num_txt,max;
			
            max=parseInt($(".goodMaxNum").val());

            /*添加数量的方法*/
            $(".goodnumplus").click(function(){
            num = $(".goodnum").val(); 
            if(num<max){
            	num++;	
            }
            
            $(".goodnum").val(num);
            var money =parseInt($(".singleprice").val());
            $(".sumprice").val(money*num);
            //ajax代码可以放这里传递到数据库实时改变总价
            });

            /*减少数量的方法*/ 
            $(".goodnummin").click(function(){
            //如果文本框的值大于0才执行减去方法
            num = $(".goodnum").val();
            var money =parseInt($(".singleprice").val());
            if(num >1){
            //并且当文本框的值为1的时候，减去后文本框直接清空值，不显示0
            if(num==1)
            { num--;
                $(".goodnum").val(num);
                $(".sumprice").val(money*num);
            }
            //否则就执行减减方法
            else
            {
            num--;
            $(".goodnum").val(num);
            $(".sumprice").val(money*num);
            }

            }
            });
        })
        </script>

</head>
<body class=" theme-blue">

   

    <div class="navbar navbar-default" role="navigation"  >
        <div class="navbar-header"  >
          <a class="" href="index.html"><span class="navbar-brand" style=""><i class="fa fa-list" style="margin-right:30px; font-size:19px;"></i>商品详细信息</span></a></div>

        <div class="navbar-collapse collapse" style="height: 1px;">

        </div>
      </div>
    </div>
    


    <div class="dialog" style="margin-top:110px;">
        <div class="panel panel-default">
            <p class="panel-heading no-collapse" style="letter-spacing:2px;"> 商品详细信息 </p>
            <div class="panel-body">
                <form action="/u/${gid}/add" method="post">
                    <div class="form-group">
                        <label>商品名称</label>
                        <input type="text" value="${goods.gname }" class="form-control span12" readOnly="true" >
                    </div>
                    <div class="form-group">
                        <label>商品单价</label>
                        <input type="text" value="${goods.gprice }" class="singleprice form-control span12" readOnly="true" >
                    </div>
                    <div class="form-group">
                        <label>商品库存</label>
                        <input type="text" value="${goods.gnum }" class="goodMaxNum form-control span12" readOnly="true" >
                    </div>
                    <div class="form-group">
                        <label>购买数量</label>
                        <a class="goodnummin btn " style="margin-left:40px; padding: 0 10px; width:40px;"><i class="fa fa-minus" ></i></a>
                        <input name="cgoodsnum" class="goodnum form-control span12" type="text" class="form-control span12"  value="1" style="width:55px; display:inline-block;text-align:center;">
                        <a class="goodnumplus btn " style="padding: 0 10px;width:40px;"><i class="fa fa-plus" ></i></a>
                    </div>
                    <div class="form-group">
                        <label>支付金额</label>
                        <input type="text" class="sumprice form-control span12" readOnly="true" value="${goods.gprice }" > 
                    </div>
                    <div class="form-group">
                     <a href="/u/${user.uid}/home"><button type="button" class="btn btn-default pull-left">返回</button></a>
                    <input  type="submit" class="btn btn-info pull-right" value="加入购物车">
                    
                </form>
            </div>
        </div>
    </div>

    
    
  
</body></html>
